package com.htj.powerbank.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.htj.powerbank.entity.Bank;
import com.htj.powerbank.service.BankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bank")
public class BankController {

    @Autowired
    BankService bankService;

    @GetMapping("/list")
    public R banklist(@RequestParam("pageNum") int pageNum,
                       @RequestParam("pageSize") int pageSize,
                       @RequestParam("sort") String sort,
                       Bank bank) {
        Boolean isDesc = new Boolean(sort.equals("+id"));
//        System.out.println(isDesc);
        Page<Bank> page = new Page<>(pageNum, pageSize);
        IPage<Bank> queryVoPage = bankService.getBankList(page,bank,isDesc);
        return R.ok(queryVoPage);
    }
}
